﻿using Sunny.UI;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PressureTest
{
    internal class Config
    {
        //配置文件路径
        static String configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.ini");

        //ini文件操作类
        IniFile ini = new IniFile(configPath);

        /// <summary> 数据库主机地址
        /// 
        /// </summary>
        public string DBHost
        {
            get
            {
                return ini.ReadString("DATABASE", "host", "");
            }
            set
            {
                ini.Write("DATABASE", "host", value);
                ini.UpdateFile();
            }
        }

        /// <summary> 数据库端口
        /// 
        /// </summary>
        public string DBPort
        {
            get
            {
                return ini.ReadString("DATABASE", "port", "");
            }
            set
            {
                ini.Write("DATABASE", "port", value);
                ini.UpdateFile();
            }
        }

        /// <summary> 数据库名称
        /// 
        /// </summary>
        public string DBName
        {
            get
            {
                return ini.ReadString("DATABASE", "name", "");
            }
            set
            {
                ini.Write("DATABASE", "name", value);
                ini.UpdateFile();
            }
        }

        /// <summary> 数据库用户
        /// 
        /// </summary>
        public string DBUser
        {
            get
            {
                return ini.ReadString("DATABASE", "user", "");
            }
            set
            {
                ini.Write("DATABASE", "user", value);
                ini.UpdateFile();
            }
        }

        /// <summary> 数据库密码
        /// 
        /// </summary>
        public string DBPwd
        {
            get
            {
                return ini.ReadString("DATABASE", "password", "");
            }
            set
            {
                ini.Write("DATABASE", "password", value);
                ini.UpdateFile();
            }
        }

        /// <summary> 运维
        /// 
        /// </summary>
        public bool Operation
        {
            get
            {
                return ini.ReadBool("OPERATION", "Operation", false);
            }
            set
            {
                ini.Write("OPERATION", "Operation", value);
                ini.UpdateFile();
            }
        }
    }
}
